# -*- coding: utf-8 -*-
import tokenize

def 字典反转(输入字典):
    输出字典 = {}
    字典关键字 = 输入字典.keys()
    for i in 字典关键字:
        输出字典.update({输入字典[i]:i})
    return 输出字典

#转译器
def 转译器(源码, 词库):
    for type, name, _,_,_ in tokenize.generate_tokens(源码):
        if type == tokenize.NAME and name in 词库:
            yield tokenize.NAME, 词库[name]
        else:
            yield type, name

def 译码(源码 , 词库):
    目标码 = tokenize.untokenize(list(转译器(源码.readline, 词库)))
    return 目标码